// class LazyMan {
//   constructor(name){
//     this.name = name
//     this.queue = []
//     setTimeout(()=>{
//       this.next()
//     },0)
//   }
//   eat(footName) {
//     let fn = ()=>{
//       console.log(`I'm eating ${footName}`)
//       this.next()
//     }
//     this.queue.push(fn)
//     return this
//   }
//   sleep(time) {
//     let fn = ()=>{
//       setTimeout(()=>{
//         this.next()
//       },time)
//     }
//     this.queue.push(fn)
//     return this
//   }
//   sleepFirst(time) {
//     let fn = ()=>{
//       setTimeout(()=>{
//         this.next()
//       },time)
//     }
//     this.queue.unshift(fn)
//     return this
//   }
//   next(){
//     let fn = this.queue.shift()
//     fn && fn.call()
//   }
// }

// function createLazyMan (name) {
//   return new LazyMan(name)
// }


// createLazyMan('Tony').eat('lunch').eat('dinner').sleepFirst(2000).sleep(5000).eat('junk food')

setImmediate(()=>{
  console.log('setImmediate 1')
})

setTimeout(()=>{
  console.log('setTimeout 1')
},0)

var p = new Promise((r)=>{
  r('promise is resolve 1')
}).then(res=>console.log(res))

process.nextTick(()=>{
  console.log('process.nextTick 1')
})

setTimeout(()=>{
  setImmediate(()=>{
    console.log('setImmediate 2')
  })
  
  setTimeout(()=>{
    console.log('setTimeout 2')
  },0)
  
  var p = new Promise((r)=>{
    r('promise is resolve 2')
  }).then(res=>console.log(res))
  
  process.nextTick(()=>{
    console.log('process.nextTick 2')
  })
},1000)

setImmediate(()=>{
  console.log('setImmediate 3')
})

setTimeout(()=>{
  console.log('setTimeout 3')
},0)

var p = new Promise((r)=>{
  r('promise is resolve 3')
}).then(res=>console.log(res))

process.nextTick(()=>{
  console.log('process.nextTick 3')
})